#include "MainWindow.h"
#include "ui_MainWindow.h"

#include <QDebug>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    testCommunicate();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::testCommunicate()
{
    m_communicateChannelPtr = QSharedPointer<CommunicateChannel>(new CommunicateChannel);

    char localIp[] = "200.200.200.1";
    int16_t localPort = 3000;
    char groupIp[] = "192.168.233.1";
    int16_t groupPort = 4000;
    bool bBind = m_communicateChannelPtr->bindAddr(localIp, localPort, groupIp, groupPort);
    if(bBind){
        bool bStart = m_communicateChannelPtr->start();
        if(!bStart){
            qDebug() << "start Communicate error";
        }
    }
    else{
        qDebug() << "bind error";
    }
}

